package com.example.maruko_course_backend.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

public class StringUtil {
  public static final String EMPTY_STR = "";
  public static final String COMMA = ",";
  public static final String CAESURA = "、";
  public static final String DASH = "ー";
  public static final String LINE_BREAK = "\n";

  public static String getExceptionStrMsg(Exception e) {
    StringWriter sw = new StringWriter();
    try (PrintWriter pw = new PrintWriter(sw)) {
      e.printStackTrace(pw);
    }
    return sw.toString();
  }

  public static String removePointSuffix(String s) {
    return s.replaceAll("[.](.*)", "");
  }

  public static int removePointSuffixToInt(String s) {
    return Integer.parseInt(removePointSuffix(s));
  }
}
